<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>实时消息</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<style>
			.mui-bar {
				background-color: #0088BB;
			}
			
			.mui-title {
				color: #FFFFFF
			}
			
			a {
				color: #FFFFFF
			}
			.mui-content-padded {
				padding: 10px;
			}
			
			body,
			body .mui-content {
				background-color: #fff !important;
			}
			
			code {
				word-wrap: break-word;
				word-break: normal;
				font-size: 90%;
				color: #c7254e;
				background-color: #f9f2f4;
				border-radius: 4px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="eqpid">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">实时消息{{eqpid}}</h1>
		</header>

		<div class="mui-content" id="moreMessage">
			<div class="mui-content-padded" style="padding-bottom: 50px;">
				<h4 class="mui-content-padded">实时消息：</h4>

				<div v-for="message in messages" class="mui-input-row">
					<code :style="{ 'color': message.COLOR }">{{message.MESSAGE}}}</code>
				</div>
			</div>
		</div>
		<script src="../../js/mui.js"></script>
		<script type="text/javascript" src="../../base.js"></script>
		<script type="text/javascript" src="../../js/vue.min.js" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init()
			var localEqp = localStorage.getItem("localEqp");

			Vue.config.devtools = true
			var app = new Vue({
				el: '#eqpid',
				data: {
					eqpid: "(" + localEqp + ")"
				}
			});

			var vm = new Vue({
				el: '#moreMessage',
				data: {
					messages: {}
				},
				mounted: function() {
					this.showMessage();
				},
				methods: {
					showMessage: function() {
						var _this = this;
						setInterval(function() {
							mui.ajax(base + '/SHOWMESSAGE/index.json', {
								data: {
									EQPID: localEqp,
									number: 30
								},
								dataType: 'json', //服务器返回json格式数据
								type: 'post', //HTTP请求类型
								timeout: 10000, //超时时间设置为10秒；
								success: function(data) {
									_this.messages = data;

								},
								error: function(xhr, type, errorThrown) {
									mui.toast(new Date() + type)
								}
							});

						}, 3000);
					}
				}
			})
		</script>
	</body>

</html>